<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    /* div>p {
      color: red;
    } */
    div>p:first-child {
      color: red;
    }

    div>p:last-child {
      color: red;
    }
  </style>
</head>

<body>
  <div>
    <p>p1</p>
    <p>p2</p>
    <p>p3</p>
    <p>p4</p>
  </div>
</body>

</html>